<%@ page language="java" import="java.util.*,com.beans.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title></title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<script type="text/javascript" src="../js/jquery-1.8.0.js"></script> 
<script type="text/javascript">
			$("#ch_checkall,#top_ch_checkall").click(function(){
				if(this.checked){
					$("input[name=ck_id]").attr("checked","checked");
				}else{
					$("input[name=ck_id]").removeAttr("checked");
				}		
			});
					
			$("table tr").mouseover(function(){
				$(this).css("background","#D3EAEF");
				$(this).siblings().css("background","white");
			});
			
			function delall(){
				if($("input[name=ck_id]:checked").size()==0){
					alert("请至少选一项!");
				}
				else{
					if(confirm('确定要删除所选项吗')){
						$("#flag").val("delall")
						form1.submit();
					}
				}
			}
</script>

<script>
	$(function(){
		$("#top_ch_checkall,#ch_checkall").click(function(){
			if(this.checked){
				$("input[name=ck_id]").prop("checked",true);
			}else{
				$("input[name=ck_id]").prop("checked",false);
			}
		})
	})
</script>
<link rel="stylesheet" type="text/css" href="../css/maintable.css" ></link>
</head>

<body>
		<div class ="div_title">
				<div class="div_titlename"> <img src="../images/san_jiao.gif" ><span>管理人员基本信息列表</span></div>
				<div class="div_titleoper">
					<input type="checkbox" id="top_ch_checkall"/> 全选 <a href="admin/admin_add.jsp"> <img src="../images/add.gif"/>添加 </a> <a href="javascript:delall()" ><img src="../images/del.gif"/>删除</a> </div>
		 </div>
		 
		 <form action="AdminServlet.do"  name="form1" method="post">
		 <input value="page" name="flag" id="flag" type="hidden">
		 <table class="main_table" id="table1">
		       <tr>
		 				<th><input type="checkbox" id="ch_checkall" /></th>
		 				<th>账号</th> 	
		 				<th>状态</th>	
		 				<th>备注</th>  
		 				<th>最后更新日期</th> 	
		 				<th>操作</th>
		 		</tr>
		 		<c:forEach var="u" items="${adminlist}">
		          <tr>
			          <td>
					 	<input type="checkbox" name="ck_id" value="${u.id}" /> 
					 </td>
			           <td>${u.adminName}</td>
			           <td>${u.state}</td>
			           <td><a title="${u.noteshow}">${u.note}</a></td>
			           <td><fmt:formatDate value="${u.editDate}" pattern="yyyy/MM/dd HH:mm:ss"/></td>
			          <td>
			           <a id=zy href="AdminServlet.do?flag=lock&id=${u.id}&state=${u.state}&pageIndex=${page.pageIndex}">${u.state==1?"锁定":"解锁"}</a> 
			           <a id=update href="AdminServlet.do?flag=gotoupdate&id=${u.id}&pageIndex=${page.pageIndex}">修改</a>  
			           <a id=delete href="AdminServlet.do?flag=delete&id=${u.id}&pageIndex=${page.pageIndex}" onclick="return deleteAdmin()"> 删除</a>
			           </td>
		          </tr>
		         </c:forEach>
		</table>
		
		
		<div class="div_page" >
			  <div class="div_page_left">    共有 <label>${page.rowCount}</label> 条记录，当前第 <label>${page.pageIndex}</label> 页，共 <label>${page.pageCount}</label> 页	</div>		
			  <div class="div_page_right" > 	 
			  			 <a href="AdminServlet.do?flag=page&pageIndex=1" >首页</a>
		  	 			 <a href="AdminServlet.do?flag=page&pageIndex=${page.pageIndex-1 }">上一页</a>
			  			 <a href="AdminServlet.do?flag=page&pageIndex=${page.pageIndex+1 }">下一页 </a>
		  	 		   	 <a href="AdminServlet.do?flag=page&pageIndex=${page.pageCount}">尾页</a>

			  <button>转到</button>
			  <input type="text" name="pageIndex" id="pageIndex" value="${page.pageIndex}"  type="number"/> 页
			</div>
				
		</div>
		</form>
		
		<script>
			function deleteAdmin(){
				var l=confirm("确认删除吗");
				if(l){
					return true;
				}else{
					return false;
				}
			}
		</script>
</body>
</html>